package com.itheima.health.dao;


import com.itheima.health.vo.MemberVO;
import com.itheima.health.vo.SetmealCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ReportDao {

//    @Select("SELECT  DISTINCT DATE_FORMAT(reg_time,'%Y-%m')  from t_huiyuan ")
//    LocalDate getMothsReport();

    @Select("SELECT count(id) FROM  t_huiyuan  WHERE reg_time between  #{monthStart} and #{monthEnd}")
    Integer getMembersReport(LocalDate monthStart,LocalDate monthEnd);


    @Select("select DISTINCT ts.name  from t_setmeal ts ,t_order_person top where  ts.id =top.stemeal_id")
    String[] getSetmealName();


    @Select("SELECT count(stemeal_id) as value,ts.name from t_order_person top ,t_setmeal ts   where top.stemeal_id=ts.id group by top.stemeal_id")
    List<SetmealCount> getSetmealCount();

    //获取今日新增会员数
    @Select("select  count(id) from t_huiyuan  where reg_time=#{date}")
    Integer getNewMember(LocalDate date);

    //获取本周新增会员数
    @Select("select   count(id)  from t_huiyuan  where  reg_time between  #{weekStart} and #{weekEnd}")
    Integer getThisWeekNewMember(LocalDate weekStart, LocalDate weekEnd);

    @Select("select   count(id)  from  t_huiyuan where reg_time between  #{monthStart} and #{monthEnd}")
    Integer getThisMothsNewNumber(LocalDate monthStart, LocalDate monthEnd);

    //总会员数
    @Select("select   count(id) from t_huiyuan ")
    Integer getTotalMember();

    @Select("select  count(id)  from t_order_person where order_date =#{today}")
    Integer getTodayOrderNumber(LocalDate today);

    @Select("select  count(id)  from t_order_person where order_date between  #{weekStart} and #{weekEnd}")
    Integer getThisWeekOrderNumber(LocalDate weekStart);

    @Select("select  count(id)  from t_order_person where order_date between  #{monthStart} and #{monthEnd}")
    Integer getThisMonthOrderNumber(LocalDate monthStart, LocalDate monthEnd);
}
